/**
 *
 */
package com.angel.dao.generic.impl;

import com.angel.dao.generic.helpers.HibernateHelper;
import com.angel.dao.generic.interfaces.TransactionStrategy;

/** Manipulate transactions logic like an strategy that you can change.
 *
 * @author William
 *
 */
public class HibernateTransactionStrategy implements TransactionStrategy{


	public void beginTransaction() {
		HibernateHelper.getCurrentSession().beginTransaction();
	}


	public void commit() {
		HibernateHelper.getCurrentSession().getTransaction().commit();
	}


	public void rollback() {
		HibernateHelper.getCurrentSession().getTransaction().rollback();
	}


	public boolean isActive() {
		return HibernateHelper.getCurrentSession().getTransaction().isActive();
	}


	public void setTimeout(int timeout) {
		HibernateHelper.getCurrentSession().getTransaction().setTimeout(timeout);
	}


	public boolean wasCommited() {
		return HibernateHelper.getCurrentSession().getTransaction().wasCommitted();
	}


	public boolean wasRolledBack() {
		return HibernateHelper.getCurrentSession().getTransaction().wasRolledBack();
	}


	public Object getCurrentSession() {
		return HibernateHelper.getCurrentSession();
	}
}
